#include "leds_control.h"

static Leds_Mode_t current_mode = LEDS_MODE_OFF;

void LedsControl_Init(){
    HAL_Leds_Init();
}

void LedsControl_SetMode(Leds_Mode_t mode) {
    current_mode = mode;
}

void LedsControl_Update(){
    switch (current_mode) {
    case LEDS_MODE_OFF:
        HAL_Leds_Control(LEDS1, OFF);
        HAL_Leds_Control(LEDS2, OFF);
        HAL_Leds_Control(LEDS3, OFF);
        HAL_Leds_Control(LEDS4, OFF);
        HAL_Leds_Control(LEDS5, OFF);
        HAL_Leds_Control(LEDS6, OFF);
        HAL_Leds_Control(LEDS7, OFF);
        HAL_Leds_Control(LEDS8, OFF);
        break;
    case LEDS_MODE_LED1:
        HAL_Leds_Control(LEDS1, ON);
        break;
    case LEDS_MODE_LED2:
        HAL_Leds_Control(LEDS2, ON);
        break;
    case LEDS_MODE_LED3:
        HAL_Leds_Control(LEDS3, ON);
        break;
    case LEDS_MODE_LED4:
        HAL_Leds_Control(LEDS4, ON);
        break;
    case LEDS_MODE_LED5:
        HAL_Leds_Control(LEDS5, ON);
        break;
    case LEDS_MODE_LED6:
        HAL_Leds_Control(LEDS6, ON);
        break;
    case LEDS_MODE_LED7:
        HAL_Leds_Control(LEDS7, ON);
        break;
    case LEDS_MODE_LED8:
        HAL_Leds_Control(LEDS8, ON);
        break;
    case LEDS_MODE_ALL:
        HAL_Leds_Control(LEDS1, ON);
        HAL_Leds_Control(LEDS2, ON);
        HAL_Leds_Control(LEDS3, ON);
        HAL_Leds_Control(LEDS4, ON);
        HAL_Leds_Control(LEDS5, ON);
        HAL_Leds_Control(LEDS6, ON);
        HAL_Leds_Control(LEDS7, ON);
        HAL_Leds_Control(LEDS8, ON);
        break;
    case LEDS_MODE_WATER:
        HAL_Leds_Control(LEDS1, ON);
        delay_ms(250);
        HAL_Leds_Control(LEDS2, ON);
        delay_ms(250);
        HAL_Leds_Control(LEDS3, ON);
        delay_ms(250);
        HAL_Leds_Control(LEDS4, ON);
        delay_ms(250);
        HAL_Leds_Control(LEDS5, ON);
        delay_ms(250);
        HAL_Leds_Control(LEDS6, ON);
        delay_ms(250);
        HAL_Leds_Control(LEDS7, ON);
        delay_ms(250);
        HAL_Leds_Control(LEDS8, ON);
        delay_ms(250);
        HAL_Leds_Control(LEDS1, OFF);
        HAL_Leds_Control(LEDS2, OFF);
        HAL_Leds_Control(LEDS3, OFF);
        HAL_Leds_Control(LEDS4, OFF);
        HAL_Leds_Control(LEDS5, OFF);
        HAL_Leds_Control(LEDS6, OFF);
        HAL_Leds_Control(LEDS7, OFF);
        HAL_Leds_Control(LEDS8, OFF);
        delay_ms(250);
        break;
    }
}